<template>
	<view class="recommend-product" v-if="isShow" :data-theme='theme()' :class="theme() || ''">
		<!--推荐-->
		<view style="width: 100%;display: flex;justify-content: center;align-items: center;">
			<view class="gang"></view>
			<span class="wenzi">热门推荐</span>
			<view class="gang"></view>
		</view>
		<view class="title d-c-c">
			<text class="line-left"></text>
			<!-- <text class="name">{{showName}}</text> -->
			<text class="line-right"></text>
		</view>
		<view class="recommend-product-list">
			<view class="item" v-for="(item, index) in listData" :key="index" @click="gotoProduct(item.product_id)">
				<view class="product-cover">
					<image :src="item.product_image" mode="aspectFill"></image>
				</view>
				<view class="product-info">
					<view class="product-title">{{ item.product_name }}</view>
					<view class="d-b-c mt20">
						<view class="price f18 theme-price" style="color:red">
							¥
							<text class="num" style="color:red">{{ item.product_sku.product_price }}</text>
							<text>天</text>
						</view>
					</view>
					<view class="d-s-c d-r" v-if="deposit"
						style="width: fit-content;     background-color: #1677FF; padding: 5rpx;margin-top:5rpx;margin-bottom: 10rpx;border-radius: 5px;color: #fff;">
						<view class="zhima-tag d-f d-r" style="width: fit-content;border-radius: 4px;">
							<image class="zhima-logo" style="height: 36rpx; width: 36rpx;"
								src="@/static/icon/zhima_white.png" mode="aspectFit"></image>
							<view
								style="color: #1677ff;line-height: 40rpx;font-size: 26rpx;margin-left: 5rpx;font-weight: bold;">
							</view>
						</view>
						<view class="zhima-describe" style="font-size:0.22rem;margin-right: 5rpx;">
							芝麻信用 | 免押金
						</view>
					</view>
				</view>
				<!-- 		<view class="d-s-c  mt10 p-0-10" >
					<view class="d-c-c mr10" style="height: 16px; padding: 0 8rpx; background: #D2EEEE;border-radius: 2px;color: #1FADAB; opacity: 0.5;">
						租完即送
					</view>
					<view class="d-c-c" style=" height: 16px; padding: 0 8rpx; background: #D2EEEE;border-radius: 2px;color: #1FADAB; opacity: 0.5;">
						顺丰包邮
					</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				/*数据*/
				listData: [],
				isShow: false,
				showName: '',
				deposit:false
			};
		},
		created() {
			this.getData();
		},
		mounted() {
			this.deposit = uni.getStorageSync('deposit')
		},
		props: ['location'],
		methods: {
			/*获取数据*/
			getData() {
				let self = this;
				let page = self.page;
				self._post(
					'product.product/recommendProduct', {
						location: self.location
					},
					function(res) {
						if (res.data.is_recommend == true) {
							self.isShow = true;
							self.showName = res.data.recommend.name;
							self.listData = res.data.list;
						}
					}
				);
			},
			/*推荐商品跳转*/
			gotoProduct(e) {
				let url = '/pages/product/detail/detail?product_id=' + e
				this.gotoPage(url);
			}
		}
	};
</script>

<style lang="scss">
	.recommend-product {
		margin-top: 40rpx;
		background-color: #ffffff;
		margin-top: 15rpx;
		padding-top: 12rpx;
	}

	.recommend-product .title {
		heigth: 100rpx;
		font-size: 30rpx;
	}

	.recommend-product .title .name {
		margin: 0 20rpx;
		font-size: 24rpx;
	}

	.recommend-product .title .line {
		position: relative;
		display: block;
		width: 100rpx;
		border-top: 1px solid red;
	}

	.recommend-product .title .line::after {
		position: absolute;
		content: '';
		display: block;
		width: 16rpx;
		height: 16rpx;
		border-radius: 50%;
		background: red;
	}

	.recommend-product .title .left-line::after {
		right: 0;
		top: -9rpx;
	}

	.recommend-product .title .right-line::after {
		left: 0;
		top: -9rpx;
	}

	.recommend-product-list {
		padding: 20rpx;
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		flex-wrap: wrap;
	}

	.recommend-product-list .item {
		width: 350rpx;
		border-radius: 20rpx;
		margin-right: 10rpx;
		margin-bottom: 20rpx;
		padding-bottom: 20rpx;
		overflow: hidden;
		background: #ffffff;
		box-shadow: 0 0 8rpx rgba(0, 0, 0, .1);
		margin-bottom: 10rpx;
	}

	.recommend-product-list .item:nth-child(2n+0) {
		margin-right: 0;
	}

	.recommend-product-list .product-cover {
		width: 220rpx;
		height: 220rpx;
		margin: 0 auto;
	}

	.recommend-product-list image {
		width: 100%;
		height: 100%;
	}

	.recommend-product-list .product-info {
		padding: 0 24rpx;
	}

	.recommend-product-list .product-title {
		height: 80rpx;
		display: -webkit-box;
		overflow: hidden;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		font-size: 30rpx;
		font-weight:900;
	}

	.recommend-product-list .price .num {
		font-size: 40rpx;
		font-weight: bold;
		font-weight:600;
	}

	.line-left {
		width: 80px;
		height: 3px;
		@include background_color("background_color");
		// background-image: linear-gradient(to right, #EBEBEB, #666666);
	}

	.line-right {
		width: 80px;
		height: 3px;
		@include background_color("background_color");
		// background-image: linear-gradient(to left, #EBEBEB, #666666);
	}
</style>